from django.db import models
import datetime,pytz
# Create your models here.

class Quesion(models.Model):
    question_text = models.CharField(max_length=200)
    pub_date = models.DateTimeField()

    def __str__(self):
        return  self.question_text

class Choice(models.Model):
    qid = models.ForeignKey(Quesion,on_delete=models.CASCADE)
    votes = models.IntegerField()
    choice_text = models.CharField(max_length=200)

    def __str__(self):
        return self.choice_text

class Item(models.Model):
    description = models.CharField(max_length=100)
    def __str__(self):
        return  self.description

class ItemCount(models.Model):
    tz = pytz.timezone('Asia/Shanghai')
    count = models.IntegerField()
    itemId = models.ForeignKey(Item,on_delete=models.CASCADE)
    pub_date = models.DateTimeField(auto_now=True)

    @classmethod
    def create(cls,_count,_itemid):

        item_count = cls(count=_count,itemId_id=_itemid)

        return item_count



